package com.project.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.bean.RecordBean;
import com.project.dao.RecordDao;
import com.project.service.RecordService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

/**
 * 日志
 */
@Service
@Transactional
public class RecordServiceImpl extends ServiceImpl<RecordDao, RecordBean> implements RecordService {
    @Override
    public Page<RecordBean> findAllRecord(int pageNO, int pageSize) {
        Page<RecordBean> page = new Page<>(pageNO,pageSize);
        IPage<RecordBean> iPage = this.page(page);
        return (Page<RecordBean>) iPage;
    }

    @Override
    public IPage<RecordBean> findName(int pageNO, int pageSize, LocalDate startTime, LocalDate endTime) {
        Page<RecordBean> pages = new Page<>(pageNO,pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        if (startTime!=null){
            wrapper.ge("record_time",startTime);
        }
        if (endTime!=null){
            wrapper.le("record_time",endTime);
        }
        IPage<RecordBean> iPage = this.page(pages,wrapper);
        return iPage;
    }
}
